#ifndef     __SENSOR_H
#define     __SENSOR_H

#include "../utils/object.h"
#include "../utils/no_copyable.h"
#include "../rtos/mutex.h"

namespace driver {

class Sensor : utils::no_copyable_t {

public:
    static constexpr uint8_t FridgeOpenMask = 0x01;
    static constexpr uint8_t FridgeCloseMask = 0x02;

    static constexpr uint8_t TubeTopMask = 0x08;
    static constexpr uint8_t DoorMask = 0x10;
    static constexpr uint8_t ComprMask = 0x20;

    Sensor();

    uint8_t read_value();

    inline bool is_fridge_close() { return 0x00 == (read_value() & FridgeCloseMask); }
    inline bool is_fridge_open() { return 0x00 == (read_value() & FridgeOpenMask); }
    inline bool is_tube_top() { return 0x00 == (read_value() & TubeTopMask); }
    inline bool is_door_open() { return 0x00 == (read_value() & DoorMask); }
    inline bool is_compr() { return 0x00 == (read_value() & ComprMask); }

private:
    rtos::Mutex m_mutex;
};

inline utils::object_t<Sensor> sensor;

}



#endif
